<?php
/*
 * Controlador generador de captcha
 *
 * Autores: 
 *                - Fuck.inc
 */
 
class CaptchaController extends AppController
{	
	public $captcha;
	public $logger = "controllers/captcha.txt";
	
	/* Instaciamos el objeto captcha */
	protected function before_filter()
	{
		$this->captcha = new Securimage();
	}
	
	/* Función que construye y muestra un código captcha */
	public function index()
	{
		// Solo desplegamos la vista
		View::response('view');
		
		$this->captcha->wordlist_file = APP_PATH . 'libs/secureimage/words/words.txt';
		$this->captcha->signature_font = APP_PATH . 'libs/secureimage/AHGBold.ttf';
		$this->captcha->ttf_file = APP_PATH . 'libs/secureimage/AHGBold.ttf';
		$this->captcha->audio_path = APP_PATH . 'libs/secureimage/AHGBold.ttf';
		$this->captcha->num_lines = 2;
		
		$this->captcha->show();
	}
	
	/* Función que valida el código captcha ingresado */
	public function check()
	{
		View::response('view');
		
		$this->respuesta = array("error" => true, "message" => ucfirst(_("wrong verification code")));
		
		if (Input::hasPost("captchacode"))
			if ($this->captcha->check(Input::post("captchacode")))
				$this->respuesta = array("error" => false, "message" => "");
	}
}


?>